package entities;

import java.io.Serializable;

import javax.persistence.*;

import dto.BookingDTO;

/**
 * Entity implementation class for Entity: PersonalizedBookingEntity
 *
 */

   
@Entity
@Table(name="PERSONALIZEDBOOKING")
@NamedQueries({
	@NamedQuery(name=PersonalizedBookingEntity.FIND_MY_BOOKINGS,
				query="SELECT b FROM PersonalizedBookingEntity b WHERE b.user = :user"),
				
	@NamedQuery(name=PersonalizedBookingEntity.FIND_INVITATION,
				query="Select b FROM PersonalizedBookingEntity b WHERE b.idBooking = :id AND b.user = :username"
				)
})

public class PersonalizedBookingEntity implements Serializable {

	private static final long serialVersionUID = 1L;

	public static final String FIND_MY_BOOKINGS = "PersonalizedBookingEntity.findMyBookings";
	
	public static final String FIND_INVITATION = "PersonalizedBookingEntity.findInvitation";
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private long idBooking;
	
	@ManyToOne (cascade= CascadeType.PERSIST)
	private PackageEntity packageChosen;
	
	
	private String user;
	
	public PersonalizedBookingEntity() {
		super();
	}
	
	public PersonalizedBookingEntity(BookingDTO booking){
		packageChosen= new PackageEntity(booking.getPackageChosen());
		user = booking.getUser();
		
	}
	public PackageEntity getPackageChosen() {
		return packageChosen;
	}

	public void setPackageChosen(PackageEntity packageChosen) {
		this.packageChosen = packageChosen;
	}

	public String getUser() {
		return user;
	}

	public void setUser(String user) {
		this.user = user;
	}
   
}

